package com.yc.favorite.mapper;

import com.yc.favorite.po.Favorite;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface FavoriteMapper {

    @Insert("insert into favorite values(default,#{flabel},#{furl},#{fdesc},#{ftags})")
    @Options(useGeneratedKeys = true, keyColumn = "fid", keyProperty = "fid")
    int insert(Favorite favorite);

    @Select("select * from favorite where fid=#{fid}")
    Favorite selectById(int id);

    @Select("select * from favorite a join tagfavorite b on a.fid=b.fid and b.tid=#{tid}")
    List<Favorite> selectByTid(int tid);

}
